07. Dive Deeper into Packages

Dive Deeper into Packages

You'll begin your dive into ROS packages by creating one of your own. All ROS packages should reside under the src directory.

Assuming you have already sourced your ROS environment and your catkin workspace, navigate to the src directory:

$ cd /home/workspace/catkin_ws/src

The syntax for creating a catkin package is:

$ catkin_create_pkg <your_package_name> [dependency1 dependency2 …]

The name of your package is arbitrary but you will run into trouble if you have multiple packages with the same name in your catkin workspace. Try to make it descriptive and unique without being excessively long. Let’s name ours “first_package” and we won’t specify any dependencies. By convention, package names are lowercase.

$ catkin_create_pkg first_package

Voilà. You just created your first catkin package! Navigating inside our newly created package reveals that it contains just two files: CMakeLists.txt and package.xml . This is a minimum working catkin package. It is not very interesting because it doesn't do anything, but it meets all the requirements for a catkin package. One of the main functions of these two files is to describe dependencies and how catkin should interact with them. We won’t pay much attention to them right now.

I mentioned earlier that ROS packages have a conventional directory structure. Let’s take a look at a more typical package.

  • scripts (python executables)
  • src (C++ source files)
  • msg (for custom message definitions)
  • srv (for service message definitions)
  • include -> headers/libraries that are needed as dependencies
  • config -> configuration files
  • launch -> provide a more automated way of starting nodes

Other folders may include

  • urdf (Universal Robot Description Files)
  • meshes (CAD files in .dae (Collada) or .stl (STereoLithography) format)
  • worlds (XML like files that are used for Gazebo simulation environments)

There are many packages that you can install. To see a list of available packages for the Kinetic distribution, take some time to explore the list of ROS package online .